package com.celesea.auth.grade.entity;

import com.celesea.auth.grade.v1.controller.request.PostRequest;
import com.celesea.auth.grade.v1.controller.request.PutRequest;
import com.celesea.framework.entity.BusEntity;
import com.celesea.framework.util.PinyinKit;
import com.celesea.framework.util.Version;

import javax.persistence.Column;
import javax.persistence.Table;

/**
 * @author JackYuan
 * @create 2017-10-25 14:20
 */
@Version
@Table(name = "grade")
public class Grade extends BusEntity {

    @Column(name = "`name`",columnDefinition = "名称")
    private String name;
    @Column(name = "`py`",columnDefinition = "拼音")
    private String py;
    @Column(name = "`sort`", columnDefinition = "排序")
    private Integer sort;

    public Grade() {
    }

    public Grade(PostRequest request) {
        super();
        this.name = request.getName();
        this.py= PinyinKit.getPinyinFirst(request.getName());
        this.sort=request.getSort();
    }

    public Grade(PutRequest request) {
        super();
        this.id = request.getId();
        this.name = request.getName();
        this.py= PinyinKit.getPinyinFirst(request.getName());
        this.sort=request.getSort();
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPy() {
        return py;
    }

    public void setPy(String py) {
        this.py = py;
    }

    public Integer getSort() {
        return sort;
    }

    public void setSort(Integer sort) {
        this.sort = sort;
    }
}
